<?php


namespace App\Http\Services\Admin;

use App\Models\CreditsAdminOplog;
use Illuminate\Support\Facades\Auth;
use ShallBuy\LaravelBase\Shared\SharedCacheFacade;

class CommonService
{
    public static $useSelectFiledAll = false;

    public function createLog($businessId, $moduleType, $actionType, $oldData, $newData)
    {
        $staff = SharedCacheFacade::getStaffUser(Auth::user()->id);
        $data = [
            'business_id' => $businessId,
            'user_id' => $staff['id'],
            'username' => $staff['username'],
            'mobile' => $staff['mobile'],
            'ip' => request()->ip(),
            'module_type' => $moduleType,
            'action_type' => $actionType,
            'old_data' => $oldData,
            'new_data' => $newData,
        ];
        CreditsAdminOplog::create($data);
    }

    public static function objRegroupArr($result)
    {
        $result['list'] = $result['data'];
        unset($result['data'], $result['first_page_url'], $result['from'], $result['last_page_url'], $result['next_page_url'], $result['path'], $result['prev_page_url'], $result['to'], $result['links']);
        return $result;
    }

}
